import request from '@/axios'
import { OrgChildParamsType, OrgPageParamsType } from './types'

//获取所有组织树
export const getTreeAllApi = (parentId: string) => {
  return request.get({ url: '/rbac-server/rbac/org/all', params: { parentId } })
}
//获取子组织数据
export const getTreeChildApi = (data: OrgChildParamsType) => {
  return request.post({ url: '/rbac-server/rbac/org/childs', data })
}

//获取当前用户的顶级组织数据
export const getTopApi = (id) => {
  return request.get({ url: '/rbac-server/rbac/org/getTop', params: { id } })
}
//分页获取组织列表数据
export const pageApi = (data: OrgPageParamsType) => {
  return request.post({ url: '/rbac-server/rbac/org/page', data })
}

//新增组织
export const addApi = (data) => {
  return request.post({ url: '/rbac-server/rbac/org/add', data })
}
//获取组织
export const getApi = (params) => {
  return request.get({ url: '/rbac-server/rbac/org/get', params })
}
//删除组织
export const delApi = (id) => {
  return request.delete({ url: '/rbac-server/rbac/org/delete', params: { id } })
}
//修改组织
export const updateApi = (data) => {
  return request.put({ url: '/rbac-server/rbac/org/update', data })
}
export const reallApi = () => {
  return request.get({ url: '/rbac-server/rbac/org/reinfo' })
}
